<?php
/**
 * Attribute form definition 
 *
 * @author guzhi
 * @since 2009-03-27
 */
 
require_once BaseUtil::getModulePath("base")  .  '/forms/BaseForm.php';
require_once   BaseUtil::getModulePath("base")  .  '/validate/Unique.php';

class AttributeForm extends BaseForm{
	public function __construct($attribute=array()){
		parent::__construct();
		if(empty($attribute)){
			$this->setAction(HttpUtil::getUrl("product", "subadditems"));
		} else {
			//$this->setAction(HttpUtil::getUrl("product", "subedit"));
		}
		
		$attribute1 = new Zend_Form_Element_Text('attribute1');
		$attribute1->setLabel($this->translate->_('attribute1'));
		$attribute1->addFilter("StringTrim");
		$attribute1->setRequired(false);
		if(isset($attribute['attribute1'])){
			$attribute1->setValue($attribute['attribute1']);
		}
		
		$value1 = new Zend_Form_Element_Hidden('value1');
		//$value1->setValue("a1,a2");
		
		$attribute2 = new Zend_Form_Element_Text('attribute2');
		$attribute2->setLabel($this->translate->_('attribute2'));
		$attribute2->addFilter("StringTrim");
		$attribute2->setRequired(false);
		if(isset($attribute['attribute2'])){
			$attribute2->setValue($attribute['attribute2']);
		}
		
		$value2 = new Zend_Form_Element_Hidden('value2');
		//$value2->setValue("b1,b2,b3");
		
		$attribute3 = new Zend_Form_Element_Text('attribute3');
		$attribute3->setLabel($this->translate->_('attribute3'));
		$attribute3->addFilter("StringTrim");
		$attribute3->setRequired(false);
		if(isset($attribute['attribute3'])){
			$attribute3->setValue($attribute['attribute3']);
		}
		
		$value3 = new Zend_Form_Element_Hidden('value3');
		//$value3->setValue("c1,c2,c3");
		
		$attribute4 = new Zend_Form_Element_Text('attribute4');
		$attribute4->setLabel($this->translate->_('attribute4'));
		$attribute4->addFilter("StringTrim");
		$attribute4->setRequired(false);
		if(isset($attribute['attribute4'])){
			$attribute4->setValue($attribute['attribute4']);
		}
		
		$value4 = new Zend_Form_Element_Hidden('value4');
		//$value4->setValue("d1,d2,d3");
			
		$attribute5 = new Zend_Form_Element_Text('attribute5');
		$attribute5->setLabel($this->translate->_('attribute5'));
		$attribute5->addFilter("StringTrim");
		$attribute5->setRequired(false);
		if(isset($attribute['attribute5'])){
			$attribute5->setValue($attribute['attribute5']);
		}
		
		$value5 = new Zend_Form_Element_Hidden('value5');
		//$value5->setValue("e1,e2,e3");
		
		$productId = new Zend_Form_Element_Hidden("productId");
		
		$this->addElements(array($attribute1, $value1, $attribute2, $value2, $attribute3, $value3, $attribute4, $value4, $attribute5, $value5, $productId));
		$this->setElementDecorators(array(
            'ViewHelper',
            array(array('div' => 'HtmlTag'), array('tag' => 'div',"class" => "form_element")),
        ));
	}
}
?>